{/* <template>
  <Index></Index>
</template> */}

{/* <script setup lang="ts"> */}
import { useMessage } from 'naive-ui';
import type { MessageOptions, MessageReactive, MessageApi } from 'naive-ui'
import type { VNodeChild } from 'vue'

// 全局消息封装
type MessageKey = keyof Omit<MessageApi, 'destroyAll'>

// const renderMessage: MessageRenderMessage = (props) => {
//   return h(
//     NAlert,
//     {
//       closable: props.closable,
//       onClose: props.onClose,
//       type: props.type === 'loading' ? 'default' : props.type,
//     },
//     {
//       default: () => props.content,
//       icon: props.icon
//     }
//   )
// }


export default defineComponent({
  name: 'GlobalApp',
  setup() {
    const message = useMessage()

  const messageCreate = (type: MessageKey) => (content: string | (() => VNodeChild), options?: MessageOptions): MessageReactive =>  {
    options = Object.assign({ duration: 10_000 }, options)
    return message[type](content, options);
  }
  const msgArr = Object.keys(message).map(item => {
    const fn = item === 'destroyAll' ? message.destroyAll : messageCreate(item as MessageKey)
    return [item, fn]
  })

  window.$message = Object.fromEntries(msgArr)
    return () => (
      <router-view />
    )
  }
})

// </script>
